package com.example.nophase.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.nophase.R;
import com.example.nophase.entity.ProjectDetailDTO;

import java.util.List;

public class StaffProjectAdapter extends BaseAdapter {
    Context context;
    List<ProjectDetailDTO> projectListItemList;

    public StaffProjectAdapter(List<ProjectDetailDTO> projectListItemList, Context context) {
        this.projectListItemList = projectListItemList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return projectListItemList.size();
    }

    @Override
    public Object getItem(int position) {
        return projectListItemList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.staff_project_list_item, null);

        //获取ListView中的TextView对象
        TextView projectNo = view.findViewById(R.id.applyfor_lv_item_num);
        TextView projectAppMoney =  view.findViewById(R.id.applyfor_lv_money);
//        TextView applyfor_lv_limit = view.findViewById(R.id.applyfor_lv_limit);
//        applyfor_lv_limit.setText(String.valueOf(projectListItemList.get(position).getStepLimitMoney()));
        if(projectListItemList.get(position).getAppStep() != null){
            projectNo.setText(projectListItemList.get(position).getProName()+"("+projectListItemList.get(position).getAppStep()+")");
        }else{
            projectNo.setText(projectListItemList.get(position).getProName());
        }

        projectAppMoney.setText(projectListItemList.get(position).getAppMoney()+"元");

        return view;

    }
}
